package com.winning.pmph.ctrl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.winning.pmph.entity.SpecialtyKnowledgeLib;
import com.winning.pmph.service.SpecialtyKnowledgeLibService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author admin
 */
@Api(value = "知识库管理/专科知识库")
@RestController
@RequestMapping("/pmph/action/specialtyKnowledgeLib")
public class SpecialtyKnowledgeLibCtrl {

    @Resource
    private SpecialtyKnowledgeLibService specialtyKnowledgeLibService;

    @ApiOperation(value = "selectList", notes = "专科知识库列表接口")
    @PostMapping("selectList")
    public Page<SpecialtyKnowledgeLib> selectList(@RequestBody SpecialtyKnowledgeLib specialtyKnowledgeLib) {
        return specialtyKnowledgeLibService.selectList(specialtyKnowledgeLib);
    }

    @ApiOperation(value = "selectAll", notes = "查询所有专科知识库下的知识库接口")
    @GetMapping("selectAll")
    public List<SpecialtyKnowledgeLib> selectAll(String id) {
        return specialtyKnowledgeLibService.lambdaQuery().ne(StringUtils.isNotBlank(id),
                SpecialtyKnowledgeLib::getId, id).list();
    }

    @ApiOperation(value = "insertOrUpdate", notes = "新建或修改专科知识库接口")
    @PostMapping("insertOrUpdate")
    public void insertOrUpdate(@RequestBody SpecialtyKnowledgeLib specialtyKnowledgeLib) {
        specialtyKnowledgeLibService.saveOrUpdate(specialtyKnowledgeLib);
    }

    @ApiOperation(value = "detailById", notes = "专科知识库列表查看详情接口")
    @GetMapping("detailById")
    public SpecialtyKnowledgeLib detailById(String id) {
        return specialtyKnowledgeLibService.getBaseMapper().selectById(id);
    }

    @ApiOperation(value = "deleteById", notes = "专科知识库列表删除接口")
    @GetMapping("deleteById")
    public void deleteById(String id) {
        specialtyKnowledgeLibService.getBaseMapper().deleteById(id);
    }
}
